package com.personal.system.controller.content.web;

import com.personal.common.result.Result;
import com.personal.system.entity.content.Note;
import com.personal.system.service.content.web.ApiNoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/blog/v1/note")
@RequiredArgsConstructor
@Api(tags = "笔记API-V1")
public class ApiNoteController {

    private final ApiNoteService apiNoteService;

    @GetMapping(value = "/")
    @ApiOperation(value = "笔记列表", httpMethod = "GET", response = Result.class, notes = "笔记列表")
    public Result selectNoteList(Integer categoryId) {
        return apiNoteService.selectNoteList(categoryId);
    }

    @PostMapping(value = "/")
    @ApiOperation(value = "添加笔记", httpMethod = "POST", response = Result.class, notes = "添加笔记")
    public Result insertNote(@RequestBody Note note) {
        return apiNoteService.insertNote(note);
    }

    @GetMapping(value = "/getMyNote")
    @ApiOperation(value = "我的笔记列表", httpMethod = "GET", response = Result.class, notes = "我的笔记列表")
    public Result selectMyNote() {
        return apiNoteService.selectMyNote();
    }

    @DeleteMapping(value = "/delete")
    @ApiOperation(value = "删除笔记", httpMethod = "DELETE", response = Result.class, notes = "删除笔记")
    public Result deleteMyNote(Integer id) {
        return apiNoteService.deleteMyNote(id);
    }

}